<%@page import="sosr.serveur.IServeurRMI"%>
<%@page import="sosr.bean.Patient"%>
<%@page import="sosr.bean.OrdonnanceBDD"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<jsp:useBean id="logon" scope="session" class="bean.Connexion"></jsp:useBean>
<jsp:useBean id="pageConfig" scope="session" class="bean.Page"></jsp:useBean>
<%
/*int pg = 0;
if (request.getParameter("page")!=null) pg = Integer.parseInt(request.getParameter("page"));

int nbpp = 5;
int from = pg * nbpp;
int to = from + nbpp;*/

int current_m = pageConfig.getMedecin().getId();

int nbordo = 0;

IServeurRMI serv = logon.getSrvRMI();
serv.open();
//ArrayList<OrdonnanceBDD> ar =  db.listOrdonnance(from,to);
ArrayList<OrdonnanceBDD> ar =  serv.listOrdonnance();
//nbordo = serv.selectNbOrdo();
serv.close();

int i = 0;
Iterator<OrdonnanceBDD> it = ar.iterator(); %>


<h1>Liste des ordonnances</h1>
<div class="viewport_list">
<%
while (it.hasNext()) { 
	OrdonnanceBDD p =it.next();
	serv.open();
	int idp = p.getIdPatient();
	int idm = p.getIdMedecin();
	Patient patient = serv.selectPatient(idp);
	if (patient==null || idm != current_m) continue;
	String civilite = patient.getCivilite();
	String nomp = patient.getNom();
	String prenomp = patient.getPrenom();
	String date = p.getDate();
	serv.close();
	
	String color = "#edf2ff";
	if (i%2 == 0) color = "#ffffff";
%>
<div style="background: <%=color %>; width: 100%" class="ln-rm" xrm="<%=i %>" id="ln-rm-<%=i %>" idp="<%=p.getId() %>" >
	<div onclick="setAction_3D('view_ordo',<%=p.getId() %>,<%=patient.getIdPatient() %>,false); hilightme('ln-rm-<%=i %>','ln-rm');">
		<div><em> [<%=date %>] </em></div>
		<div><%=civilite %></div>
		<div class="idp_name"><%=nomp %></div>
		<div><%=prenomp %></div>
	</div>
	<div class="_bu" id="rm-p-<%=i %>" style="display: none">
	<div class="view_bu" title="Consulter l'ordonnance"
		onclick="setAction_3D('view_ordo',<%=p.getId() %>,<%=patient.getIdPatient() %>,false); hilightme('ln-rm-<%=i %>','ln-rm');"></div>
</div>
</div>
<%
	i++;
}
%>
</div>
<script type="text/javascript">
$(".ln-rm").mouseover(function() {
	$("._bu").hide();
	var i = $(this).attr("xrm");
	$("#rm-p-"+i).show();
});
</script>